﻿using System;
using RenewalProjects.Libraries.Wcf.EasyProxy.ChannelHolders;
using Rhino.Mocks;

namespace RenewalProjects.Libraries.Wcf.EasyProxy.Tests.TestBuilders
{
	public class ChannelHolderBuilder<TContract>
	{
		private readonly MockRepository _mock;
		private readonly ChannelHolderBase<TContract> _channelHolder;
		
		public ChannelHolderBuilder(MockRepository mock, TContract testChannel)
		{
			_mock = mock;
			_channelHolder = mock.StrictMock<ChannelHolderBase<TContract>>(testChannel);
		}
		
		public ChannelHolderBuilder<TContract> ExpectEndCall()
		{
			_channelHolder.Expect(x => x.EndCall());
			return this;
		}

		public ChannelHolderBuilder<TContract> ExpectAbortCall()
		{
			_channelHolder.Expect(x => x.AbortCall());
			return this;
		}
		
		public ChannelHolderBase<TContract> Build()
		{
			return _channelHolder;
		}
	}
}
